/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-17 19:20:37
 * @LastEditTime: 2021-08-17 19:21:38
 * @LastEditors: changqing
 * @Usage: 
 */
var { BehaviorSubject } = require('rxjs');;
const subject = new BehaviorSubject(0); // 0 is the initial value

subject.subscribe({
  next: (v) => console.log(`observerA: ${v}`)
});

subject.next(1);
subject.next(2);

subject.subscribe({
  next: (v) => console.log(`observerB: ${v}`)
});

subject.next(3);

// Logs
// observerA: 0
// observerA: 1
// observerA: 2
// observerB: 2
// observerA: 3
// observerB: 3